#pragma once

#include <string>
#include <set>
#include <functional>
#include "Singleton.h"
#include "MsgRouter.h"
#include "usersession.h"


class AccountService
{
public:
    bool Init();

public:
    AccountService() = default;
    virtual ~AccountService() = default;

public:
    static AccountService* Instance()
	{
		return CSingleton<AccountService>::Instance();
	}

public:
    enum Sence
    {
        ACCESS_AUTH                     = 100,
        ACCESS_BALANCE                  = 101,
        ACCESS_BET                      = 102,
        ACCESS_WIN                      = 103,
        ACCESS_CBET                     = 104,
        ACCESS_BETWIN                   = 105,
        ACCESS_CBETWIN                  = 106,
        ACCESS_REWARD                   = 107,
        ACCESS_KICKOUT                  = 108,
    };

public:
    bool HandleAuth(Sence sence, const std::string& token, std::string&& trans);
    void OnAuth(MsgData&& data);
    inline void ListenOnAuth(Sence sence, std::function<void(int err, std::string&& errmsg, stUserSession* user_session, std::string&& trans)> listen)
    {
        m_auth_listen[sence] = listen;
    }
private:
    std::map<Sence, std::function<void(int err, std::string&& errmsg, stUserSession* user_session, std::string&& trans)>> m_auth_listen;

public:
    bool HandleGetAccount(Sence sence,  std::uint32_t uid, std::string&& trans);
    void OnGetAccount(MsgData&& data);
    inline void ListenOnGetAccount(Sence sence, std::function<void(int err, std::string&& errmsg, stUserSession* user_session, std::string&& trans)> listen)
    {
        m_acc_listen[sence] = listen;
    }
private:
    std::map<Sence, std::function<void(int err, std::string&& errmsg, stUserSession* user_session, std::string&& trans)>> m_acc_listen;
};















